﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.IO.IsolatedStorage;

namespace RadarGlobal.UIView
{
    public partial class SettingDlg : PhoneApplicationPage
    {
        private IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

        public SettingDlg()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (settings.Contains("MapView"))
            {
                ChangerViewMode.IsChecked = (bool)settings["MapView"];
            }
            if (settings.Contains("LangVN"))
            {
               // LanguadeSetting.IsChecked = (bool)settings["LangVN"];
            }
            if (settings.Contains("RadarZoom"))
            {
                double value;

                if (double.TryParse(settings["RadarZoom"].ToString(), out value))
                {
                    RadarSlider.Value = value;
                }
            }
        }
        private void ChangerViewMode_Unchecked(object sender, RoutedEventArgs e)
        {
            if (settings.Contains("MapView"))
            {
                settings["MapView"] = false;
            }
            else
                settings.Add("MapView", false);
        }

        private void ChangerViewMode_Checked(object sender, RoutedEventArgs e)
        {
            if (settings.Contains("MapView"))
            {
                settings["MapView"] = true;
            }
            else
                settings.Add("MapView", true);
        }

        private void RadarSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            if (RadarSlider == null) return;

            if (settings.Contains("RadarZoom"))
            {
                settings["RadarZoom"] = RadarSlider.Value;
            }
            else
                settings.Add("RadarZoom", (double)RadarSlider.Value);
        }
    }
}